$(function () {
  $("form").on("submit", function (e) {
    e.preventDefault();

    let username = $("#username").val();
    let password = $("#password").val();
    let phone = $('#phone').val();
    let sex = $('form [name=sex]').val();
    let vip = $('form [name=vip]').val();
    let question = $('#question').val();
    let answer = $('#answer').val();
    $.ajax({
      type: "POST",
      url: "http://124.223.14.236:3001/api/user/reg",
      data: {
      username: username,
      password: password,
      phone:phone,
      sex:sex,
      vip:vip,
      question:question,
      answer:answer,
    },
      success: function (res) {
        console.log(res)
        if (!res.success) {
          return alert("注册失败：" + res.msg)
        };     
        location.href = "../loginBaseCode/login.html";
      },
    });
  });
});